#pragma once

#include <map>
#include <vector>
#include <string>

struct ID3D10Device;
struct ID3D10ShaderResourceView;

namespace D3D10Utils
{
	class TextureManager
	{
	public:
        TextureManager();
		~TextureManager();
		
		void init(ID3D10Device * const device);

		__forceinline ID3D10ShaderResourceView* getRandomTexture();
		
		ID3D10ShaderResourceView* getTextureRV(const std::wstring& filename);
		
		ID3D10ShaderResourceView* getTextureArrayRV(const std::wstring& arrayName, const std::vector<std::wstring>& filenames);

		// .dds files can store cube textures in one file
		ID3D10ShaderResourceView* getCubeTextureRV(const std::wstring& filename);

	private:
		TextureManager(const TextureManager& textureMgr);
		TextureManager& operator=(const TextureManager& textureMgr);		

		void buildRandomTex();

	private:
		ID3D10Device *mDevice;

		std::map<std::wstring, ID3D10ShaderResourceView*> mTexturesRV;

		ID3D10ShaderResourceView *mRandomTextureRV;
	};
	
	ID3D10ShaderResourceView* TextureManager::getRandomTexture()
	{
		return mRandomTextureRV;
	}

	TextureManager& GetTextureManager();
}
